using System;
using UnityEngine;
using UnityEngine.UI;

namespace MaterialUI
{
	[Serializable]
	[AddComponentMenu("MaterialUI/Dialogs/Title Section", 100)]
	public class DialogTitleSection
	{
		[SerializeField]
		private Text m_Text;

		[SerializeField]
		private Graphic m_Sprite;

		[SerializeField]
		private VectorImage m_VectorImageData;

		public Text text => m_Text;

		public Graphic sprite => m_Sprite;

		public VectorImage vectorImageData => m_VectorImageData;

		public void SetTitle(string titleText, ImageData icon)
		{
			if (!string.IsNullOrEmpty(titleText) || icon != null)
			{
				if (!string.IsNullOrEmpty(titleText))
				{
					m_Text.text = titleText;
				}
				else
				{
					m_Text.gameObject.SetActive(value: false);
				}
				if (icon == null)
				{
					m_Sprite.gameObject.SetActive(value: false);
					m_VectorImageData.gameObject.SetActive(value: false);
				}
				else if (icon.imageDataType == ImageDataType.VectorImage)
				{
					m_VectorImageData.vectorImageData = icon.vectorImageData;
					m_Sprite.gameObject.SetActive(value: false);
				}
				else
				{
					m_Sprite.GetComponent<Graphic>().SetImage(icon);
					m_VectorImageData.gameObject.SetActive(value: false);
				}
			}
			else
			{
				m_Text.transform.parent.gameObject.SetActive(value: false);
			}
		}
	}
}
